<%@ Page language="C#" AutoEventWireup="true" CodeFile="query.aspx.cs" Inherits="query_class" %>%>
<!--
Copyright 2002-2011 Corey Trager
Distributed under the terms of the GNU General Public License
-->
<!-- #include file = "inc.aspx" -->
<html>
<head>
<title id="titl" runat="server">btnet query</title>
<link rel="StyleSheet" href="btnet.css" type="text/css">
<script type="text/javascript" language="JavaScript" src="sortable.js"></script>

<script type="text/javascript">

var shown = true;

function showhide_form()
{
	var frm =  document.getElementById("<% Response.Write(Util.get_form_name()); %>");
	if (shown)
	{
		frm.style.display = "none";
		shown = false;
		showhide.firstChild.nodeValue = "show form";
	}
	else
	{
		frm.style.display = "block";
		shown = true;
		showhide.firstChild.nodeValue = "hide form";
	}
}

function on_dbtables_changed()
{
    var tables_sel = document.getElementById("dbtables_select")
    selected_text = tables_sel.options[tables_sel.selectedIndex].text;
    if (selected_text != "Select Table") 
    {
        document.getElementById("query").value = "select * from " + selected_text;
    }
}
</script>
</head>

<body>

<div class=align>
<table border=0>

<tr>

	<td style="border: red solid 2px;
		background: yellow; color: #ff0000;
		font-weight: bold;
		font-size: 8pt;
		padding: 4px;">

This page is not safe on a public web server.
After you install BugTracker.NET on a public web server, please delete it.

<tr>
	<td>
		<select id="dbtables_select" runat="server" onchange="on_dbtables_changed()"/>
		<div style="float:right;"><a href='javascript:showhide_form()' id='showhide'>hide form</a></span>

<tr>
	<td>

		<form class=frm action="query.aspx" method="POST" runat="server">
			Or enter SQL:
			<br>
			<textarea rows=15 cols=70 runat="server" id="query"></textarea>
			<p>
			<input runat="server" type=submit value="Execute SQL">
		</form>

</table></div>

<%

if (exception_message != "")
{
    Response.Write("<span class=err>" + exception_message + "</span><br>");
}

if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
	SortableHtmlTable.create_from_dataset(
		Response, ds, "", "");

}
else
{
	Response.Write ("No Rows");
}
%>
</body>
</html>


